home *** CD-ROM | disk | FTP | other *** search
/ Mission 3 / Mission 3.zip / Mission 3.iso / texte / qed / src / comm.c < prev    next >
C/C++ Source or Header  |  1998-08-30  |  3KB  |  119 lines

  1. #include "global.h"
  2. #include "av.h"
  3. #include "clipbrd.h"
  4. #include "dd.h"
  5. #include "olga.h"
  6. #include "se.h"
  7. #include "comm.h"
  8.  
  9. /* Document-History für StartMeUp ********************************************/
  10. #define DHST_ADD 0xDADD
  11.  
  12. typedef struct
  13. {
  14.     char    *appname,
  15.            *apppath,
  16.            *docname,
  17.            *docpath;
  18. } DHSTINFO;
  19.  
  20. /* exportierte Variablen *****************************************************/
  21. char    *global_str1,
  22.         *global_str2;
  23. int    msgbuff[8];             /* Buffer, den send_msg verschickt */
  24.  
  25.  
  26. /* lokale Variablen **********************************************************/
  27. static DHSTINFO    *dhst = NULL;
  28. static int            dhst_id = -1;
  29.  
  30. /*****************************************************************************/
  31.  
  32. bool send_msg(int id)
  33. {
  34.     int    ret;
  35.     
  36.     msgbuff[1] = gl_apid;
  37.     msgbuff[2] = 0;
  38.     ret = appl_write(id, (int) sizeof(msgbuff), msgbuff);
  39.     return (ret > 0);
  40. }
  41.  
  42.  
  43. void send_clip_change(void)
  44. {
  45.     if ((av_shell_id >= 0) && (av_shell_status & 512))    /* Desktop informieren */
  46.     {
  47.         memset(msgbuff, 0, (int)sizeof(msgbuff));
  48.         msgbuff[0] = AV_PATH_UPDATE;
  49.         strcpy(global_str1, clip_dir);
  50.         *(char **) (msgbuff + 3) = global_str1;
  51.         send_msg(av_shell_id);
  52.     }
  53.     send_scchanged();
  54. }
  55.  
  56. void send_dhst(char *filename)
  57. {
  58.     if (dhst_id == -1)
  59.     {
  60.         long    l;
  61.  
  62.         if (getcookie("DHST", &l))
  63.             dhst_id = (int)l;
  64.         else
  65.             dhst_id = 0;
  66.     }
  67.     if (dhst_id > 0)
  68.     {
  69.         if (dhst == NULL)
  70.         {
  71.             dhst = malloc_global(sizeof(DHSTINFO));
  72.             dhst->appname = malloc_global(4);
  73.             strcpy(dhst->appname, "qed");
  74.             dhst->apppath = malloc_global(strlen(gl_appdir) + strlen("qed.app") + 1);
  75.             strcpy(dhst->apppath, gl_appdir);
  76.             strcat(dhst->apppath, "qed.app");
  77.             dhst->docname = malloc_global(sizeof(FILENAME));
  78.             dhst->docpath = malloc_global(sizeof(PATH));
  79.         }
  80.         split_filename(filename, NULL, dhst->docname);
  81.         strcpy(dhst->docpath, filename);
  82.         
  83.         msgbuff[0] = DHST_ADD;
  84.         *(DHSTINFO **)(msgbuff + 3) = dhst;
  85.         msgbuff[5] = 0;
  86.         msgbuff[6] = 0;
  87.         msgbuff[7] = 0;
  88.         send_msg(dhst_id);
  89.     }
  90. }
  91.  
  92. void init_comm(void)
  93. {
  94.     global_str1 = malloc_global(256);
  95.     global_str2 = malloc_global(256);
  96.     init_av();
  97.     init_se();
  98.     init_olga();
  99. }
  100.  
  101. void term_comm(void)
  102. {
  103.     term_olga();
  104.     term_se();
  105.     term_av();
  106.     if (global_str1 != NULL)
  107.         Mfree(global_str1);
  108.     if (global_str2 != NULL)
  109.         Mfree(global_str2);
  110.     if (dhst != NULL)
  111.     {
  112.         Mfree(dhst->appname);
  113.         Mfree(dhst->apppath);
  114.         Mfree(dhst->docname);
  115.         Mfree(dhst->docpath);
  116.         Mfree(dhst);
  117.     }
  118. }
  119.